VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Object = "{736A8444-E374-41A8-B526-1B07FD2F3F5B}#1.0#0"; "BLacKPeaRLOCX.ocx"
Begin VB.Form FrmPenjualan 
   BackColor       =   &H00000000&
   BorderStyle     =   0  'None
   Caption         =   "Penjualan"
   ClientHeight    =   5760
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   6360
   LinkTopic       =   "Form1"
   ScaleHeight     =   5760
   ScaleWidth      =   6360
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  'CenterScreen
   Begin VB.Timer tmrstandby 
      Enabled         =   0   'False
      Interval        =   100
      Left            =   5760
      Top             =   2400
   End
   Begin BLacKPeaRLOCX.BLacKFrame framepenj 
      Height          =   5775
      Left            =   0
      TabIndex        =   6
      Top             =   0
      Width           =   6375
      _ExtentX        =   11245
      _ExtentY        =   10186
      BackColor1      =   0
      BackColor2      =   4210752
      Caption         =   "Penjualan dengan Jasa"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   49152
      TitleColor1     =   0
      TitleColor2     =   4210752
      TitleGradient   =   2
      TitleHeight     =   350
      BorderColor     =   49152
      BorderWidth     =   2
      Begin VB.TextBox txthargabeli 
         BackColor       =   &H00404040&
         BorderStyle     =   0  'None
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H0000C000&
         Height          =   250
         Left            =   3120
         TabIndex        =   19
         Top             =   5400
         Visible         =   0   'False
         Width           =   1215
      End
      Begin VB.TextBox txtws 
         BackColor       =   &H00404040&
         BorderStyle     =   0  'None
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H0000C000&
         Height          =   250
         Left            =   4110
         Locked          =   -1  'True
         TabIndex        =   17
         Top             =   1125
         Width           =   1815
      End
      Begin VB.ComboBox txtnota 
         BackColor       =   &H00000000&
         Enabled         =   0   'False
         ForeColor       =   &H0000C000&
         Height          =   315
         Left            =   1440
         Sorted          =   -1  'True
         TabIndex        =   16
         ToolTipText     =   "Tekan enter untuk lanjut"
         Top             =   600
         Width           =   1695
      End
      Begin VB.TextBox txtharga 
         BackColor       =   &H00404040&
         BorderStyle     =   0  'None
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H0000C000&
         Height          =   250
         Left            =   1470
         TabIndex        =   1
         Top             =   1605
         Width           =   1215
      End
      Begin VB.TextBox txtstock 
         BackColor       =   &H00404040&
         BorderStyle     =   0  'None
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H0000C000&
         Height          =   250
         Left            =   4110
         TabIndex        =   13
         Top             =   1605
         Width           =   735
      End
      Begin BLacKPeaRLOCX.ButtonNix cmdadd 
         Height          =   375
         Left            =   1440
         TabIndex        =   3
         Top             =   2520
         Width           =   855
         _ExtentX        =   1508
         _ExtentY        =   661
         BTYPE           =   5
         TX              =   "+ Add"
         ENAB            =   -1  'True
         BeginProperty FONT {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         COLTYPE         =   2
         FOCUSR          =   0   'False
         BCOL            =   1184274
         BCOLO           =   16777215
         FCOL            =   49152
         FCOLO           =   49152
         MCOL            =   12632256
         MPTR            =   1
         MICON           =   "FrmPenjualan.frx":0000
         UMCOL           =   -1  'True
         SOFT            =   0   'False
         PICPOS          =   0
         NGREY           =   0   'False
         FX              =   0
         HAND            =   0   'False
         CHECK           =   0   'False
         VALUE           =   0   'False
      End
      Begin VB.ComboBox txtnamabar 
         BackColor       =   &H00000000&
         ForeColor       =   &H0000C000&
         Height          =   315
         Left            =   1440
         Sorted          =   -1  'True
         TabIndex        =   0
         ToolTipText     =   "Tekan enter untuk lanjut"
         Top             =   1080
         Width           =   1695
      End
      Begin VB.TextBox txtbanyak 
         BackColor       =   &H00404040&
         BorderStyle     =   0  'None
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H0000C000&
         Height          =   250
         Left            =   1470
         TabIndex        =   2
         Top             =   2085
         Width           =   735
      End
      Begin ComctlLib.ListView lvbar 
         Height          =   1935
         Left            =   240
         TabIndex        =   9
         Top             =   3000
         Width           =   5895
         _ExtentX        =   10398
         _ExtentY        =   3413
         View            =   3
         LabelWrap       =   -1  'True
         HideSelection   =   -1  'True
         _Version        =   327682
         ForeColor       =   49152
         BackColor       =   0
         BorderStyle     =   1
         Appearance      =   1
         NumItems        =   6
         BeginProperty ColumnHeader(1) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
            Key             =   ""
            Object.Tag             =   ""
            Text            =   "No"
            Object.Width           =   265
         EndProperty
         BeginProperty ColumnHeader(2) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
            SubItemIndex    =   1
            Key             =   ""
            Object.Tag             =   ""
            Text            =   "Nama Barang"
            Object.Width           =   3175
         EndProperty
         BeginProperty ColumnHeader(3) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
            SubItemIndex    =   2
            Key             =   ""
            Object.Tag             =   ""
            Text            =   "Harga"
            Object.Width           =   1764
         EndProperty
         BeginProperty ColumnHeader(4) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
            SubItemIndex    =   3
            Key             =   ""
            Object.Tag             =   ""
            Text            =   "Qty"
            Object.Width           =   529
         EndProperty
         BeginProperty ColumnHeader(5) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
            SubItemIndex    =   4
            Key             =   ""
            Object.Tag             =   ""
            Text            =   "Total"
            Object.Width           =   1940
         EndProperty
         BeginProperty ColumnHeader(6) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
            SubItemIndex    =   5
            Key             =   ""
            Object.Tag             =   ""
            Text            =   "Hargabel"
            Object.Width           =   0
         EndProperty
      End
      Begin BLacKPeaRLOCX.ButtonNix CmdBatal 
         Height          =   375
         Left            =   4920
         TabIndex        =   5
         Top             =   5040
         Width           =   1215
         _ExtentX        =   2143
         _ExtentY        =   661
         BTYPE           =   5
         TX              =   "Tutup"
         ENAB            =   -1  'True
         BeginProperty FONT {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         COLTYPE         =   2
         FOCUSR          =   0   'False
         BCOL            =   1184274
         BCOLO           =   16777215
         FCOL            =   49152
         FCOLO           =   49152
         MCOL            =   12632256
         MPTR            =   1
         MICON           =   "FrmPenjualan.frx":001C
         UMCOL           =   -1  'True
         SOFT            =   0   'False
         PICPOS          =   0
         NGREY           =   0   'False
         FX              =   0
         HAND            =   0   'False
         CHECK           =   0   'False
         VALUE           =   0   'False
      End
      Begin BLacKPeaRLOCX.ButtonNix CmdLock 
         Height          =   375
         Left            =   3600
         TabIndex        =   4
         Top             =   5040
         Width           =   1215
         _ExtentX        =   2143
         _ExtentY        =   661
         BTYPE           =   5
         TX              =   "Simpan"
         ENAB            =   -1  'True
         BeginProperty FONT {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         COLTYPE         =   2
         FOCUSR          =   0   'False
         BCOL            =   1184274
         BCOLO           =   16777215
         FCOL            =   49152
         FCOLO           =   49152
         MCOL            =   12632256
         MPTR            =   1
         MICON           =   "FrmPenjualan.frx":0038
         UMCOL           =   -1  'True
         SOFT            =   0   'False
         PICPOS          =   0
         NGREY           =   0   'False
         FX              =   0
         HAND            =   0   'False
         CHECK           =   0   'False
         VALUE           =   0   'False
      End
      Begin VB.TextBox txtnoclient 
         BackColor       =   &H00404040&
         BorderStyle     =   0  'None
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H0000C000&
         Height          =   250
         Left            =   4110
         Locked          =   -1  'True
         TabIndex        =   7
         Top             =   645
         Width           =   1815
      End
      Begin VB.Label Label8 
         BackStyle       =   0  'Transparent
         Caption         =   "*Tekan enter di text nama barang untuk memasukkan banyak beli dan klik kanan untuk membatakan belanja."
         ForeColor       =   &H00FFFFFF&
         Height          =   615
         Left            =   360
         TabIndex        =   20
         Top             =   5040
         Width           =   3015
      End
      Begin VB.Label Label7 
         BackStyle       =   0  'Transparent
         Caption         =   "WStation"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H0000C000&
         Height          =   255
         Left            =   3240
         TabIndex        =   18
         Top             =   1080
         Width           =   735
      End
      Begin VB.Shape Shape3 
         BackColor       =   &H00004040&
         BackStyle       =   1  'Opaque
         BorderColor     =   &H00C0FFC0&
         Height          =   345
         Left            =   4080
         Shape           =   4  'Rounded Rectangle
         Top             =   1080
         Width           =   1890
      End
      Begin VB.Label Label6 
         BackStyle       =   0  'Transparent
         Caption         =   "Stock"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H0000C000&
         Height          =   255
         Left            =   3240
         TabIndex        =   15
         Top             =   1560
         Width           =   735
      End
      Begin VB.Label Label5 
         BackStyle       =   0  'Transparent
         Caption         =   "Harga"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H0000C000&
         Height          =   255
         Left            =   240
         TabIndex        =   14
         Top             =   1560
         Width           =   1335
      End
      Begin VB.Shape Shape5 
         BackColor       =   &H00004040&
         BackStyle       =   1  'Opaque
         BorderColor     =   &H00C0FFC0&
         Height          =   345
         Left            =   1440
         Shape           =   4  'Rounded Rectangle
         Top             =   1560
         Width           =   1290
      End
      Begin VB.Shape Shape4 
         BackColor       =   &H00004040&
         BackStyle       =   1  'Opaque
         BorderColor     =   &H00C0FFC0&
         Height          =   345
         Left            =   4080
         Shape           =   4  'Rounded Rectangle
         Top             =   1560
         Width           =   810
      End
      Begin VB.Shape Shape1 
         BackColor       =   &H00004040&
         BackStyle       =   1  'Opaque
         BorderColor     =   &H00C0FFC0&
         Height          =   345
         Left            =   1440
         Shape           =   4  'Rounded Rectangle
         Top             =   2040
         Width           =   810
      End
      Begin VB.Label Label4 
         BackStyle       =   0  'Transparent
         Caption         =   "Banyak"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H0000C000&
         Height          =   255
         Left            =   240
         TabIndex        =   12
         Top             =   2040
         Width           =   1335
      End
      Begin VB.Label Label3 
         BackStyle       =   0  'Transparent
         Caption         =   "Nama Barang"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H0000C000&
         Height          =   255
         Left            =   240
         TabIndex        =   11
         Top             =   1080
         Width           =   1335
      End
      Begin VB.Label Label2 
         BackStyle       =   0  'Transparent
         Caption         =   "Nota"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H0000C000&
         Height          =   255
         Left            =   240
         TabIndex        =   10
         Top             =   600
         Width           =   615
      End
      Begin VB.Shape Shape2 
         BackColor       =   &H00004040&
         BackStyle       =   1  'Opaque
         BorderColor     =   &H00C0FFC0&
         Height          =   345
         Left            =   4080
         Shape           =   4  'Rounded Rectangle
         Top             =   600
         Width           =   1890
      End
      Begin VB.Label Label1 
         BackStyle       =   0  'Transparent
         Caption         =   "Client"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H0000C000&
         Height          =   255
         Left            =   3240
         TabIndex        =   8
         Top             =   600
         Width           =   735
      End
   End
End
Attribute VB_Name = "FrmPenjualan"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub cmdadd_Click()
If txtnamabar.Text = vbNullString Then
MsgBox "Data tidak lengkap.", vbInformation, "Blank"
Else
If Val(txtbanyak.Text) > Val(txtstock.Text) Then
MsgBox "Stock tidak mencukupi untuk melakukan transaksi.", vbInformation, "Min"
Exit Sub
End If


For i = 1 To lvbar.ListItems.Count
If lvbar.ListItems(i).SubItems(1) = txtnamabar.Text Then
lvbar.ListItems(i).SubItems(3) = Val(lvbar.ListItems(i).SubItems(3)) + Val(txtbanyak.Text)
lvbar.ListItems(i).SubItems(4) = Val(lvbar.ListItems(i).SubItems(2)) * Val(lvbar.ListItems(i).SubItems(3))
Exit Sub
End If

Next i

Set Vbutir = lvbar.ListItems.Add(, , lvbar.ListItems.Count + 1 & ".")
    Vbutir.SubItems(1) = txtnamabar.Text
    Vbutir.SubItems(2) = txtharga.Text
    Vbutir.SubItems(3) = txtbanyak.Text
    Vbutir.SubItems(4) = Val(txtharga.Text) * Val(txtbanyak.Text)
    Vbutir.SubItems(5) = txthargabeli.Text

txtnamabar.Text = ""
txtharga.Text = ""
txtbanyak.Text = ""
txtstock.Text = ""
txtnamabar.SetFocus
txtbanyak.Enabled = False
End If
End Sub

Private Sub CmdBatal_Click()
Unload Me
End Sub

Private Sub penjjas()
On Error GoTo hell
If lvbar.ListItems.Count = 0 Then
MsgBox "Data tidak lengkap.", vbInformation, "Blank"
Exit Sub
Else
For i = 1 To lvbar.ListItems.Count
rec.Open "SELECT penjualan.* FROM penjualan WHERE penjualan.Nota='" & txtnota.Text & "' and penjualan.namabarang='" & lvbar.ListItems(i).SubItems(1) & "'", conn, adOpenStatic, adLockOptimistic
If rec.RecordCount = 0 Then
rec.AddNew
rec(0) = txtnota.Text
rec(1) = txtnoclient.Text
rec(2) = "Jasa"
rec(3) = lvbar.ListItems(i).SubItems(1)
rec(4) = lvbar.ListItems(i).SubItems(5)
rec(5) = lvbar.ListItems(i).SubItems(2)
rec(6) = lvbar.ListItems(i).SubItems(3)
rec(7) = lvbar.ListItems(i).SubItems(4)
rec(8) = "Pending"
rec(9) = "No"
rec(10) = Format(Now, "DD")
rec(11) = Format(Now, "MM")
rec(12) = Format(Now, "YYYY")

rec.Update
rec.Close
Else
rec(6) = Val(rec(6)) + Val(lvbar.ListItems(i).SubItems(3))
rec(7) = Val(rec(7)) + Val(lvbar.ListItems(i).SubItems(4))
rec.Update
rec.Close
End If
rec.Open "select databarang.* from databarang where databarang.namabarang ='" & lvbar.ListItems(i).SubItems(1) & "'", conn, adOpenStatic, adLockOptimistic
rec(3) = Val(rec(3)) - Val(lvbar.ListItems(i).SubItems(3))
rec.Update
rec.Close
Next i

rec.Open "select aktifitas.* from aktifitas where aktifitas.no_client='" & txtws.Text & "' and aktifitas.user='" & txtnoclient.Text & "'", conn, adOpenStatic, adLockOptimistic
FrmMain.MSFlexGrid.TextMatrix(FrmMain.MSFlexGrid.Row, 9) = txtnota.Text
rec(5) = txtnota.Text
rec.Update
rec.Close

MsgBox "Data berhasil disimpan.", vbInformation, "Sukses"
Unload Me
End If

IfNoErr:
Exit Sub
hell:
 TulisError Err.Description, Err.Number, "penjjas", Me.Name
 Resume IfNoErr

End Sub

Private Sub penjjas1()
On Error GoTo hell
If lvbar.ListItems.Count = 0 Then
MsgBox "Data tidak lengkap.", vbInformation, "Blank"
Exit Sub
Else
For i = 1 To lvbar.ListItems.Count
rec.Open "SELECT penjualan.* FROM penjualan WHERE penjualan.Nota='" & txtnota.Text & "' and penjualan.namabarang='" & lvbar.ListItems(i).SubItems(1) & "'", conn, adOpenStatic, adLockOptimistic
If rec.RecordCount = 0 Then
rec.AddNew
rec(0) = txtnota.Text
rec(1) = txtnoclient.Text
rec(2) = "Jasa"
rec(3) = lvbar.ListItems(i).SubItems(1)
rec(4) = lvbar.ListItems(i).SubItems(5)
rec(5) = lvbar.ListItems(i).SubItems(2)
rec(6) = lvbar.ListItems(i).SubItems(3)
rec(7) = lvbar.ListItems(i).SubItems(4)
rec(8) = "Pending"
rec(9) = "No"
rec(10) = Format(Now, "DD")
rec(11) = Format(Now, "MM")
rec(12) = Format(Now, "YYYY")

rec.Update
rec.Close
Else
rec(6) = Val(rec(6)) + Val(lvbar.ListItems(i).SubItems(3))
rec(7) = Val(rec(7)) + Val(lvbar.ListItems(i).SubItems(4))
rec.Update
rec.Close
End If
rec.Open "select databarang.* from databarang where databarang.namabarang ='" & lvbar.ListItems(i).SubItems(1) & "'", conn, adOpenStatic, adLockOptimistic
rec(3) = Val(rec(3)) - Val(lvbar.ListItems(i).SubItems(3))
rec.Update
rec.Close
Next i

rec.Open "select status.* from status where status.no_nota ='" & FrmMain.GridStatusBayar.TextMatrix(FrmMain.GridStatusBayar.Row, 0) & "'", conn, adOpenStatic, adLockOptimistic
rec(12) = txtnota.Text
rec.Update
rec.Close
MsgBox "Data berhasil disimpan.", vbInformation, "Sukses"
Unload Me
End If

IfNoErr:
Exit Sub
hell:
 TulisError Err.Description, Err.Number, "penjjas", Me.Name
 Resume IfNoErr

End Sub

Private Sub penj()
On Error GoTo hell
If lvbar.ListItems.Count = 0 Then
MsgBox "Data tidak lengkap.", vbInformation, "Blank"
Exit Sub
Else
For i = 1 To lvbar.ListItems.Count
rec.Open "SELECT penjualan.* FROM penjualan WHERE penjualan.Nota='" & txtnota.Text & "' and penjualan.namabarang='" & lvbar.ListItems(i).SubItems(1) & "'", conn, adOpenStatic, adLockOptimistic
If rec.RecordCount = 0 Then
rec.AddNew
rec(0) = txtnota.Text
rec(1) = "Customer " & rec.RecordCount
rec(2) = "Non Jasa"
rec(3) = lvbar.ListItems(i).SubItems(1)
rec(4) = lvbar.ListItems(i).SubItems(5)
rec(5) = lvbar.ListItems(i).SubItems(2)
rec(6) = lvbar.ListItems(i).SubItems(3)
rec(7) = lvbar.ListItems(i).SubItems(4)
rec(8) = "Approve"
rec(9) = "Yes"
rec(10) = Format(Now, "DD")
rec(11) = Format(Now, "MM")
rec(12) = Format(Now, "YYYY")

rec.Update
rec.Close
Else
rec(6) = Val(rec(6)) + Val(lvbar.ListItems(i).SubItems(3))
rec(7) = Val(rec(7)) + Val(lvbar.ListItems(i).SubItems(4))
rec.Update
rec.Close
End If
rec.Open "select databarang.* from databarang where databarang.namabarang ='" & lvbar.ListItems(i).SubItems(1) & "'", conn, adOpenStatic, adLockOptimistic
rec(3) = Val(rec(3)) - Val(lvbar.ListItems(i).SubItems(3))
rec.Update
rec.Close
Next i
MsgBox "Data berhasil disimpan.", vbInformation, "Done"
Unload Me
End If
IfNoErr:
Exit Sub
hell:
 TulisError Err.Description, Err.Number, "Penj", Me.Name
 Resume IfNoErr

End Sub

Private Sub GetNot()
On Error GoTo hell
rec.Open "penjualan", conn, adOpenStatic, adLockOptimistic
If rec.RecordCount = 0 Then
txtnota.Text = "PJ-1"
rec.Close
Else
txtnota.Text = "PJ-" & rec.RecordCount + 1
rec.Close
End If

IfNoErr:
Exit Sub
hell:
 TulisError Err.Description, Err.Number, "GetNot", Me.Name
 Resume IfNoErr

End Sub

Private Sub cmdlock_Click()
If framepenj.Caption = "Penjualan" Then
penj
ElseIf framepenj.Caption = "Penjualan dengan Jasa" Then
penjjas
ElseIf framepenj.Caption = "Tambah Penjualan" Then
penjjas1
End If
End Sub

Private Sub Form_Load()
If FrmMain.MSFlexGrid.TextMatrix(FrmMain.MSFlexGrid.Row, 9) = "No" Then
GetNot
ElseIf FrmMain.GridStatusBayar.TextMatrix(FrmMain.GridStatusBayar.Row, 10) <> "No" Then
GetNot
txtnota.Text = FrmMain.MSFlexGrid.TextMatrix(FrmMain.MSFlexGrid.Row, 9)
End If
laodbar
End Sub
Private Sub laodbar()
On Error GoTo hell
rec.Open "databarang", conn, adOpenStatic, adLockOptimistic
If rec.RecordCount = 0 Then
rec.Close
Exit Sub
Else
rec.MoveFirst
While Not rec.EOF
txtnamabar.AddItem rec!namabarang
rec.MoveNext
Wend
rec.Close
End If

IfNoErr:
Exit Sub
hell:
 TulisError Err.Description, Err.Number, "loadbar", Me.Name
 Resume IfNoErr

End Sub
Private Sub lvbar_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 2 Then
    Dim Pt As POINTAPI
    Dim ret As Long
    RMenu = CreatePopupMenu()
    AppendMenu RMenu, MF_STRING, 1, "Ba&tal"
    GetCursorPos Pt
    ret = TrackPopupMenuEx(RMenu, TPM_LEFTALIGN Or TPM_RETURNCMD Or TPM_RIGHTBUTTON, Pt.X, Pt.Y, Me.hWnd, ByVal 0&)
   Select Case ret
   Case 1
If lvbar.ListItems.Count > 0 Then
    lvbar.ListItems.Remove lvbar.SelectedItem.Index
For i = 1 To lvbar.ListItems.Count
    lvbar.ListItems(i).Text = i & "."
Next i
End If
End Select
End If
End Sub

Private Sub tmrstandby_Timer()
For i = 1 To lvbar.ListItems.Count
If Val(lvbar.ListItems(i).SubItems(3)) > Val(txtstock.Text) Then
MsgBox "Stock tidak mencukupi untuk melakukan transaksi.", vbInformation, "Min"
lvbar.ListItems(i).SubItems(3) = 1
lvbar.ListItems(i).SubItems(4) = Val(lvbar.ListItems(i).SubItems(2)) * Val(lvbar.ListItems(i).SubItems(3))

Exit Sub
End If
Next i

End Sub

Private Sub txtbanyak_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmdadd_Click
End If
End Sub

Private Sub txtnamabar_KeyPress(KeyAscii As Integer)
On Error GoTo hell
If KeyAscii = 13 Then
rec.Open "select databarang.* from databarang where databarang.namabarang='" & txtnamabar.Text & "'", conn, adOpenStatic, adLockOptimistic
If rec.RecordCount = 0 Then
rec.Close
MsgBox "Nama barang tidak diketahui.", vbInformation, "Unknown"
txtnamabar.SetFocus
Else
txthargabeli.Text = rec(1)
txtharga.Text = rec(2)
txtstock.Text = rec(3)
rec.Close
txtbanyak.Enabled = True
txtbanyak.SetFocus
End If
End If

IfNoErr:
Exit Sub
hell:
 TulisError Err.Description, Err.Number, "txtnamabar_keypress", Me.Name
 Resume IfNoErr

End Sub

Private Sub txtharga_GotFocus()
txtharga.Backcolor = &H0&
txtharga.Forecolor = vbWhite
End Sub
Private Sub txtharga_LostFocus()
txtharga.Backcolor = &H404040
txtharga.Forecolor = &HC000&
End Sub
Private Sub txtnoclient_GotFocus()
txtnoclient.Backcolor = &H0&
txtnoclient.Forecolor = vbWhite
End Sub
Private Sub txtnoclient_LostFocus()
txtnoclient.Backcolor = &H404040
txtnoclient.Forecolor = &HC000&
End Sub
Private Sub txtws_GotFocus()
txtws.Backcolor = &H0&
txtws.Forecolor = vbWhite
End Sub
Private Sub txtws_LostFocus()
txtws.Backcolor = &H404040
txtws.Forecolor = &HC000&
End Sub
Private Sub txtstock_GotFocus()
txtstock.Backcolor = &H0&
txtstock.Forecolor = vbWhite
End Sub
Private Sub txtstock_LostFocus()
txtstock.Backcolor = &H404040
txtstock.Forecolor = &HC000&
End Sub
